﻿using System;
using System.Collections.Generic;

namespace UserSystemApi.Common.ResponseResults
{
    public class ResultHelp<T>
    {
        public int Code { get; set; }
        public string Msg { get; set; }
        public T Data { get; set; }
        public ResultHelp(int code, string msg, T data)
        {
            Code = code;
            Msg = msg;
            Data = data;
        }
        //增删改 成功响应(不需要给前端返回数据)
        public static ResultHelp<T> success(string msg)
        {
            return new ResultHelp<T>(200, msg, default);
        }
        //查询 成功响应(把查询结果做为返回数据响应给前端)
        public static ResultHelp<T> success(T data)
        {
            return new ResultHelp<T>(200, "success", data);
        }
        //失败响应
        public static ResultHelp<T> error(string msg)
        {
            return new ResultHelp<T>(214, msg, default);
        }
    }
}
